<?php
// $Id$
/**
 * This file contains {@link NodeDef} which is part of the PHP Content Repository
 * (phpCR), a derivative of the Java Content Repository JSR-170,  and is 
 * licensed under the Apache License, Version 2.0.
 *
 * This file is based on the code created for
 * {@link http://www.jcp.org/en/jsr/detail?id=170 JSR-170}
 *
 * @author Travis Swicegood <travis@domain51.net>
 * @copyright PHP Code Copyright &copy; 2004-2005, Domain51, United States
 * @copyright Original Java and Documentation 
 *  Copyright &copy; 2002-2004, Day Management AG, Switerland
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, 
 *      Version 2.0
 * @package phpContentRepository
 */

 
/**
 * Load the {@link phpCR} library file(s)
 */ 
require_once(dirname(__FILE__) . '/../phpCR.library.php');

phpCR::loadInterface('Value');


/**
 * Represents a {@link NodeType}.
 *
 * @see Workspace::getAccessManager(), AccessManager
 * @author PHP - Travis Swicegood <travis@domain51.net>
 * @copyright Copyright &copy; 2004-2005, Domain51
 * @package phpContentRepository
 */
interface NodeType
{
   /**
    * Returns the name of the {@link NodeType}.
    *
    * @return string
    */
    public function getName();
    
    
   /**
    * Returns TRUE if this {@link NodeType} is a mixin 
    * {@link NodeType}.  Returns FALSE if this {@link NodeType} is
    * a primary {@link NodeType}.
    *
    * @return bool
    */
    public function isMixin();
    
    
   /**
    * Returns all supertypes of this {@link NodeType} including both those directly
    * declared and those inherited. For primary types, this list will always
    * include at least nt:base. For mixin types, there is no
    * required base type.
    *
    * @see getDeclaredSupertypes()
    * @return array
    *   An array of {@link NodeType} objects.
    */
    public function getSupertypes();
    
    
   /**
    * Returns all direct supertypes as specified in the declaration of
    * this {@link NodeType}. 
    *
    * In single inheritance systems this will always be an array of size 0 or 1.
    * In systems that support multiple inheritance of {@link NodeType}s this 
    * array may be of size greater than 1.
    *
    * @see getSupertypes()
    * @return array
    *   An array of {@link NodeType} objects.
    */
    public function getDeclaredSupertypes();
    
    
   /**
    * Returns an array containing the {@link PropertyDef}s of this 
    * {@link NodeType}, including the {@link PropertyDef}s inherited from 
    * supertypes of this {@link NodeType}.
    *
    * @see getDeclaredPropertyDefs()
    * @return array
    *   An array containing the {@link PropertyDef}s.
    */
    public function getPropertyDefs();
    
    
   /**
    * Returns an array containing the {@link PropertyDef}s explicitly specified
    * in the declaration of this {@link NodeType}. 
    *
    * This does not include {@link PropertyDef}s inherited from 
    * supertypes of this {@link NodeType}.
    *
    * @see getPropertyDefs()
    * @return array
    *   An array containing the {@link PropertyDef}s.
    */
    public function getDeclaredPropertyDefs();
    
    
   /**
    * Returns an array containing the child {@link NodeDef}s of this 
    * {@link NodeType}, including the child {@link NodeDef}s inherited 
    * from supertypes of this {@link NodeType}.
    *
    * @see getDeclaredChildNodeDefs()
    * @return array
    *   An array containing the child {@link NodeDef}s.
    */
    public function getChildNodeDefs();
    
    
   /**
    * Returns an array containing the child {@link NodeDef}s explicitly
    * specified in the declaration of this {@link NodeType}. 
    *
    * This does not include child {@link NodeDef}s inherited from 
    * supertypes of this {@link NodeType}.
    *
    * @see getChildNodeDefs()
    * @return array
    *   An array containing the child {@link NodeDef}s.
    */
    public function getDeclaredChildNodeDefs();
    
    
   /**
    * Returns TRUE if setting $propertyName to
    * $value is allowed by this {@link NodeType}; otherwise returns
    * FALSE.
    *
    * @param string
    *   The name of the property
    * @param object
    *   A Value object.
    * @return bool
    */
    public function canSetProperty($propertyName, Value $value);
    
    
   /**
    * Returns TRUE if adding a child {@link Node} called
    * $childNodeName is allowed by this {@link NodeType}.
    *
    * If $nodeTypeName is specified, this should determine if the
    * child {@link Node} can be added with the specific {@link NodeType}.
    *
    * @param string
    *   The name of the child {@link Node}.
    * @param string|null
    *   The name of the {@link NodeType} of the child {@link Node}.
    * @return bool
    */
    public function canAddChildNode($childNodeName, $nodeTypeName = null);
    
    
   /**
    * Returns TRUE if removing $itemName is allowed
    * by this {@link NodeType}; otherwise returns FALSE.
    *
    * @param string
    *   The name of the child item
    * @return bool
    */
    public function checkRemoveItem($itemName);
}

